import com.qf.edu.address.Address;
import com.qf.edu.bean.HotVideo;
import com.qf.edu.service.GetBestBlockHashService;
import com.qf.edu.service.HotVideoService;
import com.qf.edu.utils.Request;

import java.security.KeyPair;
import java.util.Scanner;

/**
 * @author: 吾忆
 * @email: 2432605231@qq.com
 * @phone:13677982829
 * @desc:该类是Java项目的主函类的类，是程序的入口
 * @DateTime: 2021/12/21 13:14
 **/

public class Main {
    public static void main(String []args){
        Main test = new Main();
        test.run();
    }
    public void run(){
        System.out.println("=====java期末作业功能系统=========");
        System.out.println("本系统实现了以下功能：");
        while (true){
            menu();
        }
    }

    public void menu(){
        System.out.println("1.热门视频数据 2.比特币客户端通信 3 .比特币地址生成 0.退出");
        System.out.println("请输入你的选择");
        Scanner scanner = new Scanner(System.in);
        String  user_input =  scanner.next();
        int num = Integer.parseInt(user_input);
        switch (num){
            case 1 :
                HotVideoService service = new HotVideoService();
                service.getHotVideo();
                break;
            case 2 :
                GetBestBlockHashService getBestBlockHashService =new GetBestBlockHashService();
                System.out.println(getBestBlockHashService.getBestBlockHash());
                break;
            case 3:
                System.out.println("功能4：输出地址；功能5：校验地址是否符合规范。");
                Integer next = Integer.parseInt(scanner.next());
                if (next==4){
                Address address =new Address();
                KeyPair keyPair = address.generateKey();
                String adrStr = address.newAddress(keyPair);
                System.out.println("新地址是：" + adrStr);
                }else if (next==5){
                    Address address =new Address();
                    KeyPair keyPair = address.generateKey();
                    String adrStr = address.newAddress(keyPair);
                    boolean validate = new Address().isValidate(adrStr);
                    System.out.println(validate);
                }
                break;
            case 0:
                System.exit(0);
                break;
            default:
                System.out.println("输入有误，不支持该功能，请重试");
        }
    }
}
